package tako.wisers.com.android.apis.util;

import java.util.Iterator;
import java.util.Map;

import tako.wisers.com.android.apis.parser.ConfXMLParser;
import tako.wisers.com.android.apis.parser.xml.item.Draw;
import tako.wisers.com.android.apis.view.ViewNameIDConverse;
import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;

public class BackGroundHelper {
	public synchronized static void settingBackGround(Activity activity, Integer layoutID){
		ConfXMLParser confXMLParser = ConfXMLParser.getInstance();
		Map<String, Draw> backGroundMap = confXMLParser.getDrawListByLayout(ViewNameIDConverse.getNameFromId(layoutID));
		if(backGroundMap == null) return ;
		Iterator<Draw> itr = backGroundMap.values().iterator();
		while(itr.hasNext()){
			Draw draw = itr.next();
			View view = activity.findViewById(ViewNameIDConverse.getIdFromName(draw.getViewID()));
			if(view == null) continue;
			Drawable background = new BitmapDrawable(draw.getBackGround());
			view.setBackgroundDrawable(background);
		}
	}
}
